package cn.edu.ctbu.controller.admin;

import cn.edu.ctbu.DTO.SetmealDetailDTO;
import cn.edu.ctbu.VO.DishDetailVO;
import cn.edu.ctbu.VO.SetmealDetailVO;
import cn.edu.ctbu.result.PageResult;
import cn.edu.ctbu.result.Result;
import cn.edu.ctbu.service.ISetmealService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RequestMapping("/admin/setmeal")
@RestController
@Api(tags = "套餐相关接口")
public class SetmealController {
    @Autowired
    ISetmealService iSetmealService;

    /**
     * 分页查询套餐
     */
    @ApiOperation("分类查询套餐")
    @GetMapping
    public Result<PageResult> get(Integer page, Integer pageSize, String name, Long categoryId, Integer status){
        PageResult list=iSetmealService.get(page,pageSize,name,categoryId,status);
        return Result.success(list);
    }

    /**
     * 是否禁用
     */
    @ApiOperation("启动禁用分类")
    @GetMapping("/status")
    public Result status(Long id){
        iSetmealService.status(id);
        return Result.success();
    }

    /**
     * 删除套餐
     */
    @ApiOperation("删除套餐")
    @DeleteMapping("/delete")
    public Result del(@RequestBody List<Long> ids){
        iSetmealService.del(ids);
        return Result.success();
    }

    /**
     *根据ID获得套餐详情
     */
    @ApiOperation("根据ID获得套餐详情")
    @GetMapping("/add/{id}")
    public Result<SetmealDetailVO> getSetmealDetail(@PathVariable Long id){
        SetmealDetailVO vo=iSetmealService.getSetmealDetail(id);
        return Result.success(vo);
    }

    /**
     * 新增套餐
     */
    @ApiOperation("新增套餐")
    @PostMapping("/add")
    public Result add(@RequestBody SetmealDetailDTO dto){
        iSetmealService.add(dto);
        return Result.success();
    }

    /**
     * 修改套餐
     */
    @ApiOperation("新增套餐")
    @PutMapping("/put")
    public Result put(@RequestBody SetmealDetailDTO dto){
        iSetmealService.put(dto);
        return Result.success();
    }

}
